package cn.bocweb.spinning.view.activity;


import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.bocweb.spinning.R;
import cn.bocweb.spinning.view.common.BaseActivity;
import de.greenrobot.event.EventBus;

public class WebActivity extends BaseActivity {


    Toolbar mToolbar;

    WebView webview;
    String url;
    String title;
    Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        intent = getIntent();
        initView();
        initData();
        initToolBar();

        setContentView(R.layout.activity_web);
    }

    private void initData() {

        if (intent != null) {
            Bundle bundle = intent.getExtras();
            url = bundle.getString("url");
            title = bundle.getString("title");
            Log.e("==url+title==", url + "==" + title);

        }

    }

    @Override
    protected void onRestart() {
        super.onRestart();
        webview.loadUrl(url);
        EventBus.getDefault().register(this);
    }

    private void initView() {
        mToolbar = (Toolbar) findViewById(R.id.web_toolbar);
        webview = (WebView) findViewById(R.id.web_webview);
    }

    private void initToolBar() {
        mToolbar.setTitle(title);
        mToolbar.setTitleTextColor(getResources().getColor(R.color.white));
        mToolbar.setNavigationIcon(R.mipmap.btn_exit);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
